package cn.swu.lzr.page;

import cn.swu.lzr.JDBC.DBTools;
import com.mysql.cj.Session;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

import java.io.IOException;
import java.sql.SQLException;

public class addPageServlet extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        int CountEveryPage = 5;
        DBTools dbTools = new DBTools();
        HttpSession session = request.getSession();
        int Currentpage = (int) session.getAttribute("CurrentPage");
        try {
            if (dbTools.getCount() - (Currentpage * CountEveryPage) > 0){
                Currentpage++;
                session.setAttribute("CurrentPage",Currentpage);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        response.sendRedirect("main.html");

    }

}
